package com.by.service.impl;

import com.by.bean.ForwardInquiry;
import com.by.bean.PageBean;
import com.by.mapper.ForwardInquiryMapper;
import com.by.query.ForwardInquiryQuery;
import com.by.service.ForwardInquiryService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * date 2025/2/27 10:30
 * author bjj
 * decoration
 * version 1.0
 * since jdk11
 */
@Service
public class ForwardInquiryServiceImpl implements ForwardInquiryService {
    @Autowired
    ForwardInquiryMapper forwardInquiryMapper;
    /**
     * 根据条件分页查询
     * @param query
     * @return
     */
    @Override
    public PageBean queryList(ForwardInquiryQuery query) {
        if(query.getPage()==0){
            query.setPage(1);
        }
        if(query.getPageSize()==0){
            query.setPageSize(10);
        }
        PageHelper.startPage(query.getPage(),query.getPageSize());
        List list = forwardInquiryMapper.queryList(query);
        PageInfo pageInfo = new PageInfo(list);
        return new PageBean(query.getPage(),query.getPageSize(),pageInfo.getTotal(),list);
    }

    @Override
    public int update(ForwardInquiry forwardInquiry) {
        return forwardInquiryMapper.update(forwardInquiry);
    }


}
